home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 8 / Night Owl CD-ROM (NOPV8) (Night Owl Publisher) (1993).ISO / 034a / aecur101.arj / CONTRIB / CURSES / SRC / MATCHKEY.C < prev    next >
C/C++ Source or Header  |  1990-03-08  |  560b  |  29 lines

  1. /*------------------------------------------------------------
  2.  * 
  3.  *  matchkey.c
  4.  * 
  5.  *  copyright (c) 1988,89,90 J. Alan Eldridge
  6.  *
  7.  *  since keys are ints, we can't use strchr() to
  8.  *  see if a key is in an array of keys
  9.  * 
  10.  *  the array is terminated with K_ILLEGAL
  11.  * 
  12.  *----------------------------------------------------------*/
  13.  
  14. #include "curses.h"
  15.  
  16. int
  17. kb_matchkey(arr, val)
  18. int *arr;
  19. int val;
  20. {
  21.     int n;
  22.  
  23.     for (n = 0; *arr != K_ILLEGAL; arr++, n++)
  24.         if (*arr == val)
  25.             return n;
  26.  
  27.     return -1;
  28. }
  29.